const Base = require("../base.js");
var md5 = require("md5");
var HmacSha1 = require('crypto-js/hmac-sha1');
var Base64 = require('crypto-js/enc-base64');

const appid = "0a68c2d8"
const SecretKey = "dcad1b89aa0dfb31f596f1422f749e38"
module.exports = class extends Base {
    async indexAction() {
        try {
            const ts = new Date().getTime()
            const baseString = appid + ts
            const baseStringmd5 = md5(baseString)
            const jjner = Base64.stringify((HmacSha1(baseStringmd5, SecretKey)));
            this.success(jjner)
            // const urlse = encodeURIComponent('https://duxinggj-1251133427.cos.ap-guangzhou.myqcloud.com/dxgjAdmin/%E6%B5%8B%E8%AF%95%E8%AF%AD%E9%9F%B3/blob1683823725925.wav')
            // const iurs = "https://raasr.xfyun.cn/v2/api/upload?duration=200&signa=" + jjner + '&fileName=blob1683823725925&fileSize=11895&sysDicts=uncivilizedLanguage&appId=' + appid + '&ts=' + ts + '&audioMode=urlLink&audioUrl=' + urlse
            // const { code, content } = await this.dxPost(iurs)
            // if (code == '000000') {
            //   const jjnserr = 'https://raasr.xfyun.cn/v2/api/getResult?signa=' + jjner + '&orderId=' + content.orderId + '&appId=' + appid + '&ts=' + ts
            //   console.log(iurs);
            //   console.log(jjnserr);
            //   const res = await this.dxPost(jjnserr)
            //   return this.success(res)
            // }
            // return this.fail("请求失败")
        } catch (e) {

        }

    }
}